package com.flick.base.service;

import com.flick.base.dao.BaseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * @author flick on 2017/4/27.
 * @version 1.0
 */
public abstract class QueryAndOperateServ<T,DAO extends BaseRepository> extends QueryServ<T,DAO> {

    public T save(T t) throws Exception{
        return (T)dao.save(t);
    }

    public T save(List<T> list) throws Exception{
        return (T)dao.save(list);
    }

    public void del(Serializable id) throws Exception{
        dao.delete(id);
    }

    public void del(T t){
        dao.delete(t);
    }
    public void del(List<T> list) throws Exception{
        dao.delete(list);
    }
    public void dels(String ids) throws Exception{
        String [] idArray = ids.split(",");
        for (String id:idArray) {
//            System.out.println(id);
            del(id);
        }
    }
}
